package com.yb.web.goods;

import com.opensymphony.xwork2.ActionContext;
import com.yb.base.web.BaseAction;
import com.yb.bussiness.goods.CategoryMessageService;
import com.yb.bussiness.goods.CategoryMessageServiceImpl;
import com.yb.domain.goods.TgCategoryMessage;
import com.yb.util.comm.RequestUtil;
import com.yb.util.framework.MemoryData;

public class CategoryMessageAction extends BaseAction {
	private CategoryMessageService service;
	
	private Integer type;
	private Integer type2;
	private Long pcategoryId;
	private Long categoryId;
	private TgCategoryMessage obj;

	public CategoryMessageAction() {
		service = new CategoryMessageServiceImpl();
	}

	public String toPage() {
		try {
			ActionContext.getContext().put("categoryList", MemoryData.getCategoryList());
		} catch (Exception e) {
			log.error("", e);
		}
		return "toPage";
	}
	
	public String search(){
		try {
			if(1 == type2)
				categoryId = -1l;
			obj = service.findByParams(pcategoryId, categoryId, type, type2);
		} catch (Exception e) {
			log.error("", e);
		}
		return "showMessage";
	}
	
	public String save() {
		try {
			if(1 == obj.getType2())
				obj.setCategoryId(-1l);
			service.saveOrUpdate(obj);
		} catch (Exception e) {
			log.error("", e);
		}
		return "toPage_redirect";
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getType2() {
		return type2;
	}

	public void setType2(Integer type2) {
		this.type2 = type2;
	}

	public Long getPcategoryId() {
		return pcategoryId;
	}

	public void setPcategoryId(Long pcategoryId) {
		this.pcategoryId = pcategoryId;
	}

	public Long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	public TgCategoryMessage getObj() {
		return obj;
	}

	public void setObj(TgCategoryMessage obj) {
		this.obj = obj;
	}
	
	
	
}
